package com.example.rabbit.listener;

import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

/**
 *  死信重定向队列
 */

@Component
public class DeadLetterConsumer {
    @RabbitListener(queues = "tdl_queue",containerFactory="rabbitListenerContainerFactory")
    public void fromDeadLetter(@Payload String msg){
        System.out.println("(会报错)我是死信队列 的消费者,内容:"+msg);
          throw new RuntimeException("死信_queue 队列 处理时 报错了");
    }

    @RabbitListener(queues = "tdl_queue",containerFactory="rabbitListenerContainerFactory")
    public void fromDeadLetter2(@Payload String msg){
        System.out.println("（会超时）我是死信队列 的消费者,内容:"+msg);

    }
}
